
;----------------------------

;try to figure out a place where the user usually installs his games
(if (exists "Games:" (noreq) )
    (set @default-dest "Games:")
    (if (exists "SYS:Games" (noreq) )
        (set @default-dest "SYS:Games")
        (if (exists "Work:Games" (noreq) )
            (set @default-dest "Work:Games")
            (if (exists "JEUX:" (noreq) )
               (set @default-dest "JEUX:")
               (set @default-dest "SYS:")
            )
        )
    )
)

(message "\n\n\nThis loader needs the JST program (NOT INCLUDED)\n to be copied in your path\n\n(if you don't have it already)\n\nJST is available from aminet (game/patch) or on my site")

(set default-dest
(askdir
	(prompt ("Where should %s installed ?\nA drawer \"%s\" will automatically created." @app-name @app-name))
	(help @askdir-help)
	(default @default-dest)
	(disk)
)
)


(set #dest (tackon default-dest @app-name))

(set #CI_unit
	(askchoice
		(prompt "From which disk unit do you want\nto install the game")
		(help	@askoptions-help)
		(choices
		   "DF0:"
		   "DF1:"
		   "DF2:"
		   "DF3:"
		)
	)
)

(set #CI_drive ("DF%ld:" #CI_unit))


(set #game_ver
	(askchoice
		(prompt ("Which version of %s\ndo you want to install" @app-name))
		(help	@askoptions-help)
		(choices
		   "X-Out Original (2 disks)"
		   "X-Out Budget (1 disk)"
		)
	)
)


(makedir #dest
	(help @makedir-help)
	(infos)
)

;----------------------------



(copyfiles
	(help @copyfiles-help)
	(source "xouthd.readme")
	(dest #dest)
	(infos)
)

(if (= #game_ver 0)

(
(copyfiles
	(help @copyfiles-help)
	(source "XoutHD")
	(dest #dest)
	(infos)
)

(message ("\nInsert %s disk 1 into drive %s !" @app-name #CI_drive))
	(if
		(= 0 (run ("xout2file %ld \"%s\" 2 159 >con:///1000//CLOSE/WAIT" #CI_unit (tackon #dest "Xout.d1") )))
		("")
		(abort "\"xout2file\" must be in your PATH !")
	)

(message ("\nInsert %s disk 2 into drive %s !" @app-name #CI_drive))
	(if
		(= 0 (run ("xout2file %ld \"%s\" 2 120 >con:///1000//CLOSE/WAIT" #CI_unit (tackon #dest "Xout.d2") )))
		("")
		(abort "\"xout2file\" must be in your PATH !")
	)

))

(if (= #game_ver 1)

(
(copyfiles
	(help @copyfiles-help)
	(source "XoutBHD")
	(dest #dest)
	(infos)
)

(message ("\nInsert %s disk into drive %s !" @app-name #CI_drive))
	(if
		(= 0 (run ("disk2file %ld \"%s\" >con:///1000//CLOSE/WAIT" #CI_unit (tackon #dest "Xoutb.d1") )))
		("")
		(abort "\"disk2file\" must be in your PATH !")

	)

))
